MPC Tensor Prototype

All functionality in this notebook is just a proof of concept. The tensor is not stable. For a full survey of the tech behind this tensor, see the following blogpost

mortendahl.github.io/2017/04/17/private-deep-learning-with-mpc/


In [1]:
import numpy as np
from syft.mpc.rss import MPCRepo
from syft.mpc.rss.tensor import RSSMPCTensor

In [2]:
bob = MPCRepo()
alice = MPCRepo()
sam = MPCRepo()

bob.set_siblings(alice,sam)
alice.set_siblings(sam,bob)
sam.set_siblings(bob,alice)

In [3]:
r = RSSMPCTensor(alice,np.random.rand(10))

In [4]:
r


Out[4]:
RSSMPCTensor: array([0.50083556, 0.96614524, 0.9928066, 0.21695686, 0.09230825,
       0.41738036, 0.93996725, 0.26363021, 0.74307937, 0.02905819], dtype=object)

In [5]:
r+r


Out[5]:
RSSMPCTensor: array([1.00167112, 1.93229048, 1.9856132, 0.43391372, 0.1846165,
       0.83476072, 1.8799345, 0.52726042, 1.48615874, 0.05811638], dtype=object)

In [6]:
r*r


Out[6]:
RSSMPCTensor: array([0.25083626, 0.93343663, 0.98566495, 0.04707028, 0.00852081,
       0.17420636, 0.88353843, 0.06950089, 0.55216695, 0.00084438], dtype=object)

In [7]:
r - r


Out[7]:
RSSMPCTensor: array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=object)

In [8]:
r.dot(r)


Out[8]:
3.90578595

In [10]:
r.sum()


Out[10]:
5.16216789

In [ ]: